import { createRouter, createWebHistory } from 'vue-router'
import jsonIndexView from '../views/jsonView/jsonIndexView.vue'
import eleIndexView from '../views/ele/eleIndexView.vue'
import echartsIndexView from '../views/echarts/echartsIndexView.vue'
import otherIndexView from '../views/other/otherIndexView.vue'
import lineIndexView from '../views/line/lineIndexView.vue'
import scatterIndexView from '../views/scatter/scatterIndexView.vue'
import barIndexView from '../views/bar/barIndexView.vue'
import pieIndexView from '../views/pie/pieIndexView.vue'
import Login from '../views/LoginView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    // {
    //   name: '404',
    //   path: '/:catchAll(.*)',
    //   component: () => import(`@/views/error/404.vue`)
    // },
    {
      path: '/',
      redirect: '/Login',
  },
    {
      path: '/Login',
      name: 'Login',
      // redirect: '/Login',
      component: Login,
      meta: {
        auth: true,
        keepAlive: false
      },
  },
    {
      path: '/jsonIndexView',
      title:'json数据创建',
      name: 'jsonIndexView',
      id: '1',
      icon:'location',
      component: jsonIndexView,
      redirect: '/jsonIndexView/jsonGetView',
      children: [
        // {
        //   path: '/',
        //   name: 'jsonIndexView',
        //   component: jsonIndexView
        // },
        {
        path: '/jsonIndexView/jsonGetView',
          title:'角色账号',
          name: '角色账号',
          component: () => import('../views/jsonView/jsonGetView.vue')
        },
        {
          path: '/jsonIndexView/jsonPostView',
          title:'json数据创建3',
          name: 'jsonPostView',
          component: () => import('../views/jsonView/jsonPostView.vue')
        },
        
      ]
    },
    {
      path: '/eleIndexView',
      title:'ele模块',
      name: 'eleIndexView',
      id: '2',
      icon:'Notification',
      component: eleIndexView,
      children:[
        // {
        //   path: '/eleIndexView/eleIndexView',
        //   name: 'eleIndexView',
        //   title:'ele模块',
        //   component: eleIndexView
        // },
        {
          path: '/eleIndexView/eleHomeView',
          name: '步骤条',
          title:'ele模块',
          component: () => import('../views/ele/eleHomeView.vue'),
        },
        {
          path: '/eleIndexView/imageUploadView',
          name: '图片上传',
          title:'imageUploadView',
          component: () => import('../views/ele/imageUploadView.vue'),
        },
        {
          path: '/eleIndexView/imageUploadView2',
          name: '图片上传2',
          title:'imageUploadView2',
          component: () => import('../views/ele/imageUploadView2.vue'),
        },
        {
          path: '/eleIndexView/dialogOrFromView',
          name: '弹窗+表单',
          title:'dialogOrFromView',
          component: () => import('../views/ele/dialogOrFromView.vue'),
        },
        {
          path: '/eleIndexView/eleHomeView2',
          name: 'eleHomeView2',
          title:'ele模块3',
          component: () => import('../views/ele/eleHomeView2.vue'),
        }
      ]

    },
    {
      path: '/echartsIndexView',
      title:'echarts模块',
      name: 'echartsIndexView',
      id: '3',
      icon:'document',
      component: echartsIndexView,
      children: [
        {
          path: '/echartsIndexView/echartslineView',
          name: '折线图图',
          title:'echarts模块',
          component: () => import('../views/echarts/echartslineView.vue'),
        },
        {
          path: '/echartsIndexView/echartsScatterView',
          name: '散点图图',
          title:'echarts模块',
          component: () => import('../views/echarts/echartsScatterView.vue'),
        },
        {
          path: '/echartsIndexView/echartsColumnView',
          name: '柱状图图',
          title:'echarts模块',
          component: () => import('../views/echarts/echartsColumnView.vue'),
        },
        {
          path: '/echartsIndexView/echartsPieView',
          name: '饼状图图',
          title:'echarts模块',
          component: () => import('../views/echarts/echartsPieView.vue'),
        },
        {
          path: '/echartsIndexView/echartslineOrPieView',
          name: '折线图和饼图',
          title:'echarts模块',
          component: () => import('../views/echarts/echartslineOrPieView.vue'),
        },
        {
          path: '/echartsIndexView/echartsHoneView',
          name: 'echartsHoneView',
          title:'echarts模块',
          component: () => import('../views/echarts/echartsHoneView.vue'),
        }
      ]

    }
    ,
   
    {
      path: '/line',
      title:'折线图模块',
      name: '折线图模块',
      id: '5',
      icon:'setting',
      component: lineIndexView,
      children:[
        {
          path: '/line/IndexView',
          name: '折线图',
          title:'折线图',
          component: () => import('../views/line/IndexView.vue'),
        },
        {
          path: '/line/lineView',
          name: '折线图一',
          title:'折线图一',
          component: () => import('../views/line/lineView.vue'),
        },
        {
          path: '/line/lineView2',
          name: '折线图二',
          title:'折线图二',
          component: () => import('../views/line/lineView2.vue'),
        },
        {
          path: '/line/lineView3',
          name: '折线图三',
          title:'折线图三',
          component: () => import('../views/line/lineView3.vue'),
        },
        {
          path: '/line/lineView4',
          name: '折线图四',
          title:'折线图四',
          component: () => import('../views/line/lineView4.vue'),
        },
        {
          path: '/line/lineView5',
          name: '折线图五',
          title:'折线图五',
          component: () => import('../views/line/lineView5.vue'),
        },
        {
          path: '/line/lineView6',
          name: '折线图六',
          title:'折线图六',
          component: () => import('../views/line/lineView6.vue'),
        },
        {
          path: '/line/lineView7',
          name: '折线图七',
          title:'折线图七',
          component: () => import('../views/line/lineView7.vue'),
        }

      ]

    },
   
    {
      path: '/scatter',
      title:'散点图模块',
      name: '散点图模块',
      id: '8',
      icon:'setting',
      component: scatterIndexView,
      children:[
        {
          path: '/scatter/IndexView',
          name: '散点图模块',
          title:'散点图模块',
          component: () => import('../views/scatter/IndexView.vue'),
        },
        {
          path: '/scatter/scatterView',
          name: '散点图一',
          title:'散点图一',
          component: () => import('../views/scatter/scatterView.vue'),
        }
      ]

    }
    ,
    {
      path: '/bar',
      title:'柱状图模块',
      name: '柱状图模块',
      id: '7',
      icon:'setting',
      component: barIndexView,
      children:[
        {
          path: '/bar/IndexView',
          name: '柱状图模块',
          title:'柱状图模块',
          component: () => import('../views/bar/IndexView.vue'),
        },
        {
          path: '/bar/barView',
          name: '柱状图一',
          title:'柱状图一',
          component: () => import('../views/bar/barView.vue'),
        },
        {
          path: '/bar/barView2',
          name: '柱状图二',
          title:'柱状图二',
          component: () => import('../views/bar/barView2.vue'),
        },
        {
          path: '/bar/barView3',
          name: '柱状图三',
          title:'柱状图三',
          component: () => import('../views/bar/barView3.vue'),
        },
        {
          path: '/bar/barView4',
          name: '柱状图四',
          title:'柱状图四',
          component: () => import('../views/bar/barView4.vue'),
        },
        {
          path: '/bar/barView5',
          name: '柱状图五',
          title:'柱状图五',
          component: () => import('../views/bar/barView5.vue'),
        }
      ]

    }
    ,
   
    {
      path: '/pie',
      title:'饼图',
      name: '饼图模块',
      id: '6',
      icon:'setting',
      component: pieIndexView,
      children:[
        {
          path: '/pie/IndexView',
          name: '饼图',
          title:'饼图',
          component: () => import('../views/pie/IndexView.vue'),
        },
        {
          path: '/pie/pieView',
          name: '饼图一',
          title:'饼图一',
          component: () => import('../views/pie/pieView.vue'),
        },
        {
          path: '/pie/pieView2',
          name: '饼图二',
          title:'饼图二',
          component: () => import('../views/pie/pieView2.vue'),
        },
        {
          path: '/pie/pieView3',
          name: '饼图三',
          title:'饼图三',
          component: () => import('../views/pie/pieView3.vue'),
        },
        {
          path: '/pie/pieView4',
          name: '饼图四',
          title:'饼图四',
          component: () => import('../views/pie/pieView4.vue'),
        },
        {
          path: '/pie/pieView5',
          name: '饼图五',
          title:'饼图五',
          component: () => import('../views/pie/pieView5.vue'),
        },
        {
          path: '/pie/pieView6',
          name: '饼图六',
          title:'饼图六',
          component: () => import('../views/pie/pieView6.vue'),
        },
        {
          path: '/pie/pieView7',
          name: '饼图七',
          title:'饼图七',
          component: () => import('../views/pie/pieView7.vue'),
        }
      ]

    }
    ,
    {
      path: '/otherIndexView',
      title:'other模块',
      name: 'otherIndexView',
      id: '4',
      icon:'setting',
      component: otherIndexView,
      children:[
        {
          path: '/otherIndexView/otherHomeView',
          name: 'otherHomeView',
          title:'other模块',
          component: () => import('../views/other/otherHomeView.vue'),
        }
      ]

    }
  ]
})


//全局前置守卫
//导航守卫
router.beforeEach(function(to, from, next) {
  let token = sessionStorage.getItem("token");
  
  if (!token) {
    if (to.path == '/Login') {
      next()
    } else {
      next('/Login')
      // router.push('/login')
      // next()
      console.log(to.path,"sadsa2222");
    }
   
  } else {

    // if () {
      
    // }
    next()
  }
});



export default router
